package com.research.demo.toolkit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;


public class ConfigTool {
    private static String path;
    private static Logger log = LoggerFactory.getLogger(ConfigTool.class);

    static {
        String rulesPropertyFile = com.google.common.io.Resources.getResource("conf.property").getPath();
        try {
            path = URLDecoder.decode(rulesPropertyFile, "utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            log.info("error" + e);
        }
        log.info("配置文件路径:" + path);
    }

    /**
     * 根据指定的key获取对应的配置值
     */
    public static String getByKey(String key) {
        return ConfigHelper.getByKey(path, key);
    }
}
